(function() {
	/**上传头像部分**/
	var input_file = $("input[type=file]"),
		img_file = $(".jibxx_headleft img");
	input_file.on("change", function() {
			var file = this.files[0];
			if(!/image\/\w+/.test(file.type)) {
				shanchu2.css("display", "block");
				shanchuchenggong.text("请传入有效图片");
			} else if(file.fileSize >= 5242880) {
				shanchu2.css("display", "block");
				shanchuchenggong.text("上传图片要小于5M");
			}else{
				if(window.FileReader) {
					var fr = new FileReader();
					fr.onloadend = function(e) {
						img_file[0].src = e.target.result;
					};
					fr.readAsDataURL(file);
					//              location.href="ji_bxx.html";
				}	
			}
		})
		/*判断名字是不是满足规范*/
	var nc_input = $(".jibxx_nicheng input"), //获取昵称的值
		nc_tishi = $(".jibxx_nicheng  a");
	nc_input.on("change", function() {
		var nc_val = $(".jibxx_nicheng input").val(),
			r_2 = /^[_]{4,32}$/;
		if(r_2.test(nc_val)) {
			nc_tishi.css("opacity", "1");
		} else if(nc_val.length <= 4 || nc_val.length >= 32 || isNaN(Number(nc_val)) == false) {
			nc_tishi.css("opacity", "1");
		} else {
			nc_tishi.css("opacity", "0");
		}
	})

	/***遮罩层****/
	var bianhong = $(".bianhong"),
		shanchu2 = $("#shanchu2"),
		chacha = $("#chacha"),
		o5_ok = $("#o5_ok"),
		xieyi2 = $(".xieyi"),
		o5_dele = $("#o5_dele"),
		xieyichacha = $("#xieyichacha"), //协议叉叉
		xieyi = $("#xieyi"), //协议按钮
		o5_no = $("#o5_no"),
		tixian_mask = $(".tixian_mask"), //协议遮罩层
		querenshanchu = $("#querenshanchu"),
		shanchu1 = $("#shanchu1"),
		shanchuchenggong = $("#shanchuchenggong");
	bianhong.on("click", function() {
		shanchu2.css("display", "block");
		shanchuchenggong.text(bianhong.text());
	})
	chacha.on("click", function() {
		shanchu2.css("display", "none");
	})

	/***不二定制开店协议****/
	var checkbox = $("input[type='checkbox']");
	/*****判断当所有空间为只读的时候，不能点击******/
	
		xieyi2.on("click", function() {
			tixian_mask.css("display", "block");
			xieyichacha.on("click", function() {
				tixian_mask.css("display", "none");
			})
			xieyi.on("click", function() {
				tixian_mask.css("display", "none");
				checkbox.prop("checked", "checked");
			})
		})
	
	/*******保存部分*******/
	var baocun=$("#baocun"),
		shenhe=$(".dianppsz_shenhe"),
		shenheyuanyin=$(".btn_500");
	baocun.on("click",function(){
		shanchu1.css("display","block");
		querenshanchu.text("提交成功，请等待审核");
		o5_dele.on("click",function(){
			shanchu1.css("display","none");
		})
		o5_ok.on("click",function(){
			shanchu1.css("display","none");
			/*******确定后要做的事情——————所有控件只能只读******/
			shenhe.css("display","none");
			shenhe.css("display","block");
			shenheyuanyin.text("审核中");
			$("input[type='file']").attr("disabled","disabled");
			$("input").attr("readonly","readonly");
			$("textarea").attr("readonly","readonly");
			$("button").attr("readonly","readonly");
		})
		o5_no.on("click",function(){
			shanchu1.css("display","none");
		})
	})
})();